package com.fin.quant.web.controller;

import com.fin.quant.app.asset.service.AssetService;
import com.fin.quant.app.vo.*;
import com.fin.quant.rpc.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 资产相关API控制器
 */
@RestController
@RequestMapping("/api/v1/assets")
@Slf4j
public class AssetController {

    @Autowired
    private AssetService assetService;

    /**
     * 获取资产列表
     */
    @GetMapping
    public Result<AssetListResponse> getAssets(@Valid GetAssetsRequest request) {
        log.info("获取资产列表请求: {}", request);
        return assetService.getAssets(request);
    }

    /**
     * 获取单个资产详情
     */
    @GetMapping("/{assetId}")
    public Result<AssetDetailResponse> getAssetDetail(@PathVariable Long assetId) {
        log.info("获取资产详情请求: assetId={}", assetId);
        return assetService.getAssetDetail(assetId);
    }

    /**
     * 搜索资产
     */
    @GetMapping("/search")
    public Result<AssetListResponse> searchAssets(@Valid SearchAssetsRequest request) {
        log.info("搜索资产请求: {}", request);
        return assetService.searchAssets(request);
    }

    /**
     * 应用筛选
     */
    @PostMapping("/filter")
    public Result<AssetListResponse> applyFilter(@Valid @RequestBody ApplyFilterRequest request) {
        log.info("应用筛选请求: {}", request);
        return assetService.applyFilter(request);
    }
}
